package cn.my.framework.common.repo;

import cn.my.framework.common.entity.User;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

/**
 * Created by zhangl_lc on 2017/7/4.
 */
@CacheConfig(cacheNames = "users")
public interface UserRepo extends JpaRepository<User,Integer> {

    User findByCode(String code);

    User findByCodeAndStatus(String code, String category);

    @Cacheable(key = "#name",condition = "#name.contains('刘')")
    List<User> findByNameLike(String name);

    List<User> findByCategory(String category);

    @Cacheable(key = "#name+'_'+#category")
    List<User> findByNameLikeAndCategoryIs(String name, String category);
}
